package com.example.lol.ui;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.example.lol.R;
import com.example.lol.ui.adapter.NewsAdapter;
import com.example.lol.ui.bean.NewBean;
import java.util.ArrayList;
import java.util.List;

public class SecondHomeFragment extends Fragment {
    private String[] title = new String[]{"        wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwefweagwwwegwegawgweg。",
            "       weeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee。",
            "       weeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeew。",
            "       tewwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww。",
            "       wettttttttttttttttttttttttttttttttttttttttttttttttttttttt！"
    };
    private int[] cover = new int[]{R.drawable.zyxs_5,
            R.drawable.zyxs_5,
            R.drawable.zyxs_5,
            R.drawable.zyxs_5,
            R.drawable.zyxs_5};

    private List<NewBean> initData() {
        List<NewBean> list = new ArrayList<>();
        for (int i = 0; i < 5; i++) {
            list.add(new NewBean()
                    .setTitle(title[i % title.length])
//                    .setHot((int) (Math.random() * 1000))
                    .setDrawable(cover[i % cover.length]));
        }
        return list;
    }
    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_home_1, container, false);
        RecyclerView textView = view.findViewById(R.id.tv_text);
        textView.setLayoutManager(new LinearLayoutManager(this.getActivity()));
        NewsAdapter newsAdapter=new NewsAdapter();
        newsAdapter.setList(initData());
        textView.setAdapter(newsAdapter);
        return view;
    }
}